<template>
    <!-- 分类 -->
    <div class="type1">
        <p class="title"># 类型1</p>
        <div class="type_infos">
            <div class="left">
                <div class="type_move" v-for="(v_type,index) in videos" :key="index" @click="playVideo(v_type)">
                    <div class="move">
                        <p @mouseenter="downSynopsis()" @mouseleave="upSynopsis()">简介</p>
                        <div class="type_mask" @mouseenter="downSynopsis()" @mouseleave="upSynopsis()">
                            <div class="description">&nbsp;&nbsp;</div>
                        </div>
                        <img :src="file_path+v_type.videoCoverPic" @mouseenter="show_mask(2)">
                    </div>
                    <div class="type_info">
                        <p class="type_title">{{v_type.videoTitle}}</p>
                        <p class="type_author">作者：{{v_type.videoAuthor}}</p>
                    </div>
                    <div class="move_mask" @mouseenter="show_mask(2)" @mouseleave="hide_mask()">
                        <img class="play" src="/static/images/play.png">
                    </div>
                </div>
            </div>
            <p class="rank">排行榜</p>
            <div class="right">
                <ul>
                    <li :class="{'active':now_index==index,'unactive':now_index!=index}" v-for="(v_type,index) in videos" :key="index" @mousemove="modifyActive(index)">
                        <span :style="medal[index]">{{index+1}}</span>
                        <img :src="file_path+v_type.videoCoverPic">
                        <div class="li_title">{{v_type.videoTitle}}</div>
                    </li>
                </ul>
            </div>
        </div>
    </div>
</template>

<script>
import video_url from './url'
import file_path from './file_url'

export default {
    data(){
        return{
            type1_array: [],
            videos:[],
            url: video_url[2].url,
            file_path: file_path[0],
            now_index:0,
            medal:[
                'background-color:gold',
                'background-color:rgb(204, 204, 204)',
                'background-color:rgba(163, 99, 14, 0.76)',
                '','','','','','',''
            ],
        }
    },
    methods:{
        downSynopsis(){
            let title_init_element = event.target.parentNode.children[3];
            let mask_element = event.target.parentNode.children[1];

            $(title_init_element).stop().hide();
            $(mask_element).stop().slideDown(200);
        },
        upSynopsis(){
            let title_init_element = event.target.parentNode.children[3];
            let mask_element = event.target.parentNode.children[1];

            $(mask_element).stop().slideUp(200);
            $(title_init_element).stop().show();
        },
        show_mask(flag){
            let title_init_element = event.target.parentNode.parentNode.lastChild;
            let play_element = event.target.parentNode.children[2];
            if(flag == 1){
                for(let i=0; i<this.all_array.length; i++){
                    if(this.all_array[i].lastChild != title_init_element){
                        $(this.all_array[i].lastChild).stop().fadeOut(300);
                    }
                }
            }else if(flag == 2){
                for(let i=0; i<this.type1_array.length; i++){
                    if(this.type1_array[i].lastChild != title_init_element){
                        $(this.type1_array[i].lastChild).stop().fadeOut(300);
                    }
                }
            }
            
            $(title_init_element).stop().fadeIn(300);
            $(play_element).stop().fadeIn(350);
        },
        hide_mask(){
            let title_init_element = event.target.parentNode.lastChild;
            let play_element = event.target.parentNode.children[2];
            $(title_init_element).stop().fadeOut(300);
            $(play_element).stop().fadeOut(350);
        },
        modifyActive(count){
            let lis = event.target.parentNode.parentNode.children;
            
            for(let i=0; i<lis.length; i++){
                if(i != count){
                    $(lis[i]).removeClass("active");
                    $(lis[i]).addClass("unactive");
                }else{
                    $(lis[count]).removeClass("unactive");
                    $(lis[count]).addClass("active");
                }
            }
        },
        playVideo(video){
            const { href } = this.$router.resolve({
                path:"/playVideo",
                query:{
                    id: video.id,
                }
			});
			window.open(href, '_blank');
        },
    },
    created(){
        this.$axios({
            url: this.url,
            params:{
                videoCategory: 1,
            }
        }).then(res => {
            this.videos = res.data;
        })
    },
    mounted(){
        // 先给页面注册滚动事件
        document.addEventListener('scroll',this.scroll, true)
        this.type1_array = $(".classification .type1 .type_infos .left .type_move");
    }
}
</script>

<style>
.classification .type1{
    width: 1368px;
    height: 550px;
}
.classification .type1 .type_infos{
    position: relative;
    width: 1220px;
    height: 450px;
    margin-left: 5%;
    margin-top: 20px;
}
.classification .type1 .type_infos .left{
    position: absolute;
    width: 850px;
    height: 440px;
    top: 20px;
}
.classification .type1 .type_infos .rank{
    position: absolute;
    top: -10px;
    right: 220px;
    width: 100px;
    height: 30px;
    /* background-color: blue; */
    font-size: 20px;
    letter-spacing: 2px;
    font-weight: bold;
    color: #409eff;

}
.classification .type1 .type_infos .right{
    position: absolute;
    width: 300px;
    height: 400px;
    right: 20px;
    top: 25px;
    /* background-color: red; */
}
.type1 .title{
    width: 1250px;
    height: 40px;
    margin-top: 10px;
    margin-left: 50px;
    padding-left: 1.5%;
    border-bottom: 2px solid #ddd;

    font-size: 25px;
    line-height: 40px;
    font-weight: bold;
    letter-spacing: 2px;
    color: #409eff;
}
.classification .type1 .type_infos .left .type_move{
    position: relative;
    width: 200px;
    height: 200px;
    float: left;
    margin-top: 20px;
    margin-left: 35px;
    /* background-color: green; */
}
.classification .type1 .type_infos .left .type_move .move img{
    width: 190px;
    height: 130px;
    margin-left: 5px;
    margin-top: -15px;
    cursor: pointer;
}
.classification .type1 .type_infos .left .type_move .move .type_mask{
    position: absolute;
    display: none;
    width: 190px;
    height: 130px;
    background-color: #333;
    opacity: .8;
    z-index: 5;
    top: 0;
    left: 5px;
}
.classification .type1 .type_infos .left .type_move .move p{
    width: 190px;
    height: 20px;
    background-color: #333;
    opacity: .95;
    color: rgb(255, 255, 255);
    border-radius: 3px;
    margin-top: -20px;
    margin-left: 5px;
    cursor: pointer;

    font-size: 14px;
    text-align: center;
    line-height: 20px;
    letter-spacing: 5px;
}
.classification .type1 .type_infos .left .type_move .move .description{
    width: 150px;
    height:100px;
    margin-left: 15px;
    border-radius: 0.5rem;
    line-height: 19px;
    user-select: none;
    padding: 6px 5px;
    font-size: 12px;
    font-weight: bold;
    letter-spacing: 1px;
    color: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 5;
    -webkit-box-orient: vertical;
}
.classification .type1 .type_infos .left .type_move .type_info{
    width: 190px;
    height: 60px;
    margin-left: 5px;
    /* background-color: red; */
}
.classification .type1 .type_infos .left .type_move .type_info .type_title{
    position: absolute;
    width: 175px;
    height: 40px;
    padding-left: 5px;
    padding-right: 5px;
    margin-top: 0px;

    font-size: 15px;
    line-height: 20px;
    color: #333;
    z-index: 5;

    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
}
.classification .type1 .type_infos .left .type_move .type_info .type_author{
    position: absolute;
    width: 175px;
    height: 20px;
    bottom: 5px;
    margin-left: 5px;
    margin-top: 30px;
    font-size: 10px;
    line-height: 20px;
    color: #999;
}
.classification .type1 .type_infos .left .type_move .move_mask .play{
    position: absolute;
    left: 80px;
    top: 50px;
    width: 30px;
    height: 30px;
    cursor: pointer;
    z-index: 6;
}
.classification .type1 .type_infos .left .type_move .move_mask{
    display: none;
    position: absolute;
    left: 0;
    top: 0;
    width: 190px;
    height: 130px;
    margin-left: 5px;
    cursor: pointer;
    background: rgba(51, 51, 51,.5)
}
/* 类型1（type1） */
.classification .type1{
    width: 1368px;
    height: 550px;
}
.classification .type1 .type_infos{
    position: relative;
    width: 1220px;
    height: 450px;
    margin-left: 5%;
    margin-top: 20px;
}
.classification .type1 .type_infos .left{
    position: absolute;
    width: 850px;
    height: 440px;
    top: 20px;
}
.classification .type1 .type_infos .rank{
    position: absolute;
    top: -10px;
    right: 220px;
    width: 100px;
    height: 30px;
    /* background-color: blue; */
    font-size: 20px;
    letter-spacing: 2px;
    font-weight: bold;
    color: #409eff;

}
.classification .type1 .type_infos .right{
    position: absolute;
    width: 300px;
    height: 400px;
    right: 20px;
    top: 25px;
    /* background-color: red; */
}
.classification .type1 .type_infos .left .type_move{
    float: left;
    margin-left: 10px;
}
.classification .type1 .type_infos .right ul li{
    position: relative;
    width: 300px;
    height: 34px;
    /* border-bottom: 1px solid #ddd; */
    cursor: pointer;
}
.classification .type1 .type_infos .right ul li span{
    position: absolute;
    display: inline-block;
    width: 20px;
    height: 20px;
    left: 0;
    text-align: center;
    line-height: 20px;
    font-size: 12px;
}
.classification .type1 .type_infos .right ul .unactive span{
    top: 7px;
}
.classification .type1 .type_infos .right ul .active span{
    top: 37px;
}
.classification .type1 .type_infos .right ul .unactive img{
    display: none;
}
.classification .type1 .type_infos .right ul .unactive .li_title{
    position: absolute;
    width: 270px;
    height: 34px;
    left: 25px;
    font: 0;
    line-height: 34px;

    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
}
.classification .type1 .type_infos .right ul .active{
    height: 94px;
}
.classification .type1 .type_infos .right ul .active img{
    position: absolute;
    display: block;
    width: 130px;
    height: 80px;
    top: 7px;
    left: 25px;
}
.classification .type1 .type_infos .right ul .active .li_title{
    position: absolute;
    width: 140px;
    height: 60px;
    top: 17px;
    right: 0px;
    line-height: 30px;

    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
</style>